#include <iostream>
#include <fstream>

#include"LibDGGSBase/DGGSDefine.hpp"
#include <ctime>
using namespace NNU::DGGS;
using namespace NNU::DGGS::Base;


/// <summary>
/// 计算PDOP
/// </summary>
/// <param name="srcGridFilePath">网格文件路径</param>
/// <param name="gridExtFormat">网格文件格式</param>
/// <param name="srcSatFilePath">卫星文件路径</param>
/// <param name="satExtFormat">卫星文件格式</param>
/// <param name="tagFilePath">目标文件路径</param>
///  <param name="satSyetem">卫星系统</param>
///  <param name="pGridDimX">网格维度X</param>
///  <param name="pBlockDimX">块维度X</param>
void calculatePdop(const char* srcGridFilePath,
                   const char* gridExtFormat,
                   const char* srcSatFilePath,
                   const char* satExtFormat,
                   const char* satSyetem,
                   double timeStep,
                   const char* tagFilePath,
                   int gridDimX,
                   int blockDimX
                   );

/// <summary>
/// 帮助信息
/// </summary>
void help();

int main(int argc, char *argv[])
{
    if(argc<2)
    {
        help();
        return 1;
    }
    if(argc<10)
    {
        std::cout<<"parameter is not enough"<<std::endl;
        help();
        return 1;
    }

    ///网格文件路径
    const char* srcGridFilePath=argv[1];
    ///网格文件格式
    const char* gridExtFormat=argv[2];
    ///卫星文件路径
    const char* srcSatFilePath=argv[3];
    ///卫星文件格式
    const char* satExtFormat=argv[4];
    ///卫星系统
    const char* satSyetem=argv[5];
    ///时间间隔
    double timeStep=std::stoi(argv[6]);
    ///目标文件路径
    const char* tagFilePath=argv[7];

    ///GPU网格维度X
    int pGridDimX=std::stoi(argv[8]);
    ///GPU块维度X
    int pBlockDimX=std::stoi(argv[9]);

    auto start = std::clock();
    calculatePdop( srcGridFilePath, gridExtFormat,srcSatFilePath, satExtFormat,satSyetem,timeStep,tagFilePath,pGridDimX,pBlockDimX);
    auto end = std::clock();
    double elapsed = double(end - start) / CLOCKS_PER_SEC;
    std::cout << "calculatePdop spends time: " << elapsed << " second" << std::endl;
    return 1;
}


void help()
{
    std::cout << "Usage: " << "calculatePdop.exe" << " [argv]" << std::endl;
    std::cout << "argv:" << std::endl;
    std::cout << "  <filePath1>    Source grid file path" << std::endl;
    std::cout << "  <ext1>     Grid file extension format" << std::endl;
    std::cout << "  <filePath2>    Source satellite file path" << std::endl;
    std::cout << "  <ext2>     Satellite file extension format" << std::endl;
    std::cout << "  <system>   Satellite system" << std::endl;
    std::cout << "  <step>     Time step" << std::endl;
    std::cout << "  <filePath3>  Tag file path" << std::endl;
    std::cout << "  <dimx>     Grid dimension X" << std::endl;
    std::cout << "  <blockx>   Block dimension X" << std::endl;

    std::cout<<std::endl;

    std::cout << "Options:" << std::endl;
    std::cout << "  -h         Display this help message" << std::endl;
}